<?php

namespace app\admin\model;

// 引入TP基础模型
use think\Model;

/**
 * 用户收藏模型
 */
class Collection extends Model
{
    // 设置数据表名称
    protected $name = 'collection';

    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime';

    protected $updateTime = false;

    protected $append = [
        'createtime_text'
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        $createtime_text = !empty($data['createtime']) ? date("Y-m-d H:m",$data['createtime']) : '';

        return $createtime_text;
    }

    public function questions()
    {
        return $this->belongsTo('app\admin\model\Questions', 'questions_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}